/*
* 路由渲染
* */
const setIndex = (data) => {
  let nData = []
  let home = {
    path: '/indexHome',
    component: resolve => require(['../components/index/body/home.vue'], resolve),
    children: [{
      name: 'indexItem',
      path: '/indexHome/nationwide/:code',
      component: resolve => require([`../components/index/page/nationwide.vue`], resolve)
    }]
  }
  nData.push(home)
  return nData
}
const setModule = (data) => {
  let nData = []
  let home = {
    path: '/moduleHome',
    component: resolve => require(['../components/module/body/home.vue'], resolve),
    children: []
  }
  for (let i = 0; i < data.length; i++) {
    let path1 = data[i].modulePath
    let moduleItems = data[i].moduleItems
    if (path1 !== null) {
      home.children.push({
        path: `/${path1}`,
        component: resolve => require([`../components/module/page/${path1}/${path1}.vue`], resolve)
      })
    } else {
      for (let j = 0; j < moduleItems.length; j++) {
        let path2 = moduleItems[j].modulePath
        home.children.push({
          path: `/${path2}`,
          component: resolve => require([`../components/module/page/${path2}/${path2}.vue`], resolve)
        })
      }
    }
  }
  nData.push(home)
  return nData
}
export default {
  setIndex,
  setModule
}

